#ifndef WXSPARENT_H
#define WXSPARENT_H

#include "wxsitem.h"

#include <prep.h>


class wxsParent: public wxsItem {
  public:


    wxsParent( wxsItemResData* Data, const wxsItemInfo* Info, long PropertiesFlags, const wxsEventDesc* Events, const wxsStyleSet* StyleSet );


    virtual ~wxsParent();


    inline int GetChildCount() { return ( int )Children.Count(); }


    wxsItem* GetChild( int Index );


    bool AddChild( wxsItem* Child, int Position = -1 );


    void UnbindChild( int Index );


    void UnbindChild( wxsItem* Child );


    int MoveChild( int OldIndex, int NewIndex );


    int GetChildIndex( wxsItem* Child );


    bool IsGrandChild( wxsItem* Child, bool Safe = false );


    void StoreExtraData( int Index, TiXmlElement* Element );


    void RestoreExtraData( int Index, TiXmlElement* Element );


    wxsPropertyContainer* GetChildExtra( int Index );


    inline bool CanAddChild( wxsItem* Item, bool ShowMessage ) { return OnCanAddChild( Item, ShowMessage ); }


    inline bool IsChildPreviewVisible( wxsItem* Child ) { return OnIsChildPreviewVisible( Child ); }


    inline bool EnsureChildPreviewVisible( wxsItem* Child ) { return OnEnsureChildPreviewVisible( Child ); }

  protected:






    virtual wxsPropertyContainer* OnBuildExtra() { return 0; }


    virtual wxString OnXmlGetExtraObjectClass() { return wxEmptyString; }


    virtual bool OnCanAddChild( wxsItem*, bool ) { return true; }


    virtual void OnAddChildQPP( wxsItem* Child, wxsAdvQPP* QPP );







    void OnEnumChildProperties( wxsItem* Child, long Flags );


    virtual bool OnXmlRead( TiXmlElement* Element, bool IsXRC, bool IsExtra );


    virtual bool OnXmlWrite( TiXmlElement* Element, bool IsXRC, bool IsExtra );


    virtual bool OnXmlReadChild( TiXmlElement* Elem, bool IsXRC, bool IsExtra );


    virtual bool OnXmlWriteChild( int Index, TiXmlElement* Elem, bool IsXRC, bool IsExtra );


    virtual bool OnIsChildPreviewVisible( M_Code_unused wxsItem* Child ) { return true; }


    virtual bool OnEnsureChildPreviewVisible( M_Code_unused wxsItem* Child ) { return false; }

  private:


    virtual wxsParent* ConvertToParent() { return this; }


    WX_DEFINE_ARRAY( wxsItem*, wxArrayItem );
    WX_DEFINE_ARRAY( wxsPropertyContainer*, wxArrayExtra );

    wxArrayItem  Children;   ///< \brief Array of child items
    wxArrayExtra Extra;
    friend class wxsItem;
};

#endif
